package 剑指offer;

import noffer.base.TreeNode;

/**
 * @author zhangjunfei
 * @date 2023/8/25 13:50
 */
public class O_28 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) {
            return true;
        }
        return compare(root.left, root.right);
    }

    boolean compare(TreeNode left,TreeNode right){
        return (left==null&&right==null)||(left!=null&&right!=null)&&(left.val==right.val)
                &&compare(left.left,right.right)&&compare(left.right,right.left);
    }

}
